using System;
using NHibernate;

namespace Caramel.NHibernate
{
	public static class UnitOfWorkExtensions
	{
		public static ISession GetSession(this IUnitOfWork work)
		{
			var nhibernateWork = work as INHibernateUnitOfWork;

			if (nhibernateWork == null)
			{
				throw new NotSupportedException("GetSession is only supported for INHibernateUnitOfWork type.");
			}

			return nhibernateWork.Session;
		}
	}
}
